package com.test.ml.yqs.web;

import com.test.ml.yqs.entity.TqzTask;
import com.test.ml.yqs.service.TqzTaskService;
import com.test.ml.yqs.utills.ResultJson;
import com.test.ml.yqs.vo.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

/**
 * @author 马亮
 * @version V1.0
 * @Description: 管理定时任务
 */
@RestController
@RequestMapping("/yqs/task")
public class TaskController {

    @Autowired
    private TqzTaskService taskService;

    /**
     * 查询
     * @param page
     * @return
     */
    @RequestMapping(value = "taskList" ,method = RequestMethod.GET)
    public ResultJson tasklist(@RequestParam("taskName") String taskName, Page page){
        return taskService.queryList(taskName,page);
    }

    /**
     * 新增
     * @param task
     * @return
     */
    @RequestMapping(value="addTask",method = RequestMethod.POST)
    public ResultJson addTask(@RequestBody TqzTask task){
        if(StringUtils.isEmpty(task.getId())){
            return taskService.addTask(task);
        }else{
            return taskService.updateTask(task);
        }


    }
    @RequestMapping(value="delete",method = RequestMethod.POST)
    public ResultJson deleteTask(@RequestParam String ids){
        String[] id=ids.split(",");
        return taskService.deleteTask(id);
    }

}